/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package net.tygzs.easygem;

import java.io.File;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import net.tygzs.easygem.configuration.PluginConfig;
import org.bukkit.plugin.java.JavaPlugin;

/**
 * 主类
 *
 * @author thtTNT
 */
public class Main extends JavaPlugin
{

    public static Main plugin;
    private PluginConfig pluginConfig;

    @Override
    public void onEnable()
    {
        plugin = this;
        getLogger().info("宝石插件已经加载");
        File file = new File(getDataFolder(), "config.yml");
        if (!getDataFolder().exists())
        {
            getDataFolder().mkdirs();
        }
        if (!file.exists())
        {
            saveDefaultConfig();
        }
        pluginConfig = new PluginConfig();
        try
        {
            Metrics metrics =new Metrics(this);
            metrics.start();
        } catch (IOException ex)
        {
            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
        }
        
        getCommand("EasyGem").setExecutor(new net.tygzs.easygem.commandExecutor.EasyGem());
        getCommand("RepairStone").setExecutor(new net.tygzs.easygem.commandExecutor.RepairStone());
        getServer().getPluginManager().registerEvents(new net.tygzs.easygem.Listener.DropListener(),this);
    }

    /**
     * 获取配置类
     *
     * @return 配置类
     */
    public PluginConfig getPluginConfig()
    {
        return this.pluginConfig;
    }
}
